package com.example.tests;

import static com.example.fw.RandomizeHelper.generateRandomSuffix;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.io.IOException;

import org.testng.annotations.Test;

import utils.SortedListOf;

import com.example.fw.Contact;

public class TestContactCreation extends TestBase
{

	@Test
	public void shouldCreateContactWithValidData() throws IOException
	{
		SortedListOf<Contact> oldList = app.getContactHelper().getContacts();

		Contact contact = new Contact()
				.setFirstname(generateRandomSuffix("Firstname"))
				.setLastname(generateRandomSuffix("Lastname"));

		app.getContactHelper().createContact(contact);

		SortedListOf<Contact> newList = app.getContactHelper().getContacts();

		assertThat(newList, equalTo(oldList.withAdded(contact)));

	}
}
